cmake_minimum_required(VERSION 3.5 FATAL_ERROR)

project(recipe-04 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_library(sum_integers sum_integers.cpp)

find_package(Boost REQUIRED COMPONENTS unit_test_framework)         # 找到测试组件unit_test_framework

add_executable(cpp_test test.cpp)
target_link_libraries(cpp_test
        PRIVATE sum_integers Boost::unit_test_framework             # 链接unit_test_framework
    )

enable_testing()                                                    # 添加测试案例
add_test(
        NAME cpp_test
        COMMAND $<TARGET_FILE:cpp_test>
)